#include "projHeader.h"

mapElt::mapElt(void)
{
	sym = ' ';
	color = 0;
	author = new char [5];
	strcpy (author, "none");
	description = new char [5];
	strcpy (description, "none");
	changed = true;
}

mapElt::mapElt(char sym, int color)
{
	this->sym = sym;
	this->color = color;
	author = new char [5];
	strcpy (author, "none");
	description = new char [5];
	strcpy (description, "none");
	changed = true;
}

mapElt::mapElt(char sym, int color, char* author, char* description)
{
	this->sym = sym;
	this->color = color;
	if (!strlen (author))
	{
		this->author = new char [5];
		strcpy (this->author, "none");
	}
	else 
	{
		this->author = new char [strlen(author)+1];
		strcpy (this->author, author);
	}

	if (!strlen (description))
	{
		this->description = new char [5];
		strcpy (this->description, "none");
	}
	else
	{
		this->description = new char [strlen(description)+1];
		strcpy (this->description, description);
	}
	changed = true;
}

void mapElt::setAll(char sym, int color, char* author, char* description)
{
	this->sym = sym;
	this->color = color;
	delete [] this->author;
	delete [] this->description;
	if (!strlen (author))
	{
		this->author = new char [5];
		strcpy (this->author, "none");
	}
	else 
	{
		this->author = new char [strlen (author)+1];
		strcpy (this->author, author);
	}

	if (!strlen (description))
	{
		this->description = new char [5];
		strcpy (this->description, "none");
	}
	else
	{
		this->description = new char [strlen(description)+1];
		strcpy (this->description, description);
	}
	changed = true;
}

void mapElt::setChar (char sym, int color)
{
	this->sym = sym;
	this->color = color;
	delete [] author;
	delete [] description;
	author = new char [5];
	strcpy (author, "none");
	description = new char [5];
	strcpy (description, "none");
	changed = true;

}

char mapElt::getSym(void)
{
	return sym;
}
int mapElt::getColor(void)
{
	return color;
}
char* mapElt::getAuthor(void)
{
	//COORD c;
	//c.X = 0;
	//c.Y = 45;
	//SetConsoleCursorPosition (h,c);
	//cout << this->author;
	//delete [] author;
	//author = new char [strlen(this->author)+1];
	/*strcpy (author, this->author);
	cout << " :: " << author;*/
	return this->author;
}
char * mapElt::getDescription(void)
{
	//delete [] description;
	//description = new char [strlen(this->description)+1];
	//strcpy (description, this->description);
	return description;
}

bool mapElt::isChanged (void)
{
	return changed;
}

mapElt::~mapElt(void)
{
	delete [] author;
	delete [] description;
}

void mapElt::showed (void)
{
	changed = false;
}
